package edu.zju.gis.dldsj.service.impl;

import edu.zju.gis.dldsj.dao.UserDataFieldMapper;
import edu.zju.gis.dldsj.entity.DataField;
import edu.zju.gis.dldsj.service.UserDataFieldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author yanlo yanlong_lee@qq.com
 * @version 1.0 2018/08/09
 */
@Service
public class UserDataFieldServiceImpl implements UserDataFieldService {
    @Autowired
    private UserDataFieldMapper fieldMapper;

    @Override
    public DataField select(Integer pk) {
        return fieldMapper.selectByPrimaryKey(pk);
    }

    @Override
    public int insert(DataField userDataField) {
        return fieldMapper.insertSelective(userDataField);
    }

    @Override
    public void update(DataField userDataField) {
        fieldMapper.updateByPrimaryKeySelective(userDataField);
    }

    @Override
    public void delete(Integer integer) {
        fieldMapper.deleteByPrimaryKey(integer);
    }

    @Override
    public boolean isExist(Integer integer) {
        return fieldMapper.selectByPrimaryKey(integer) != null;
    }

    @Override
    public List<DataField> getByPage(int offset, int size) {
        return fieldMapper.selectByPage(offset, size);
    }

    @Override
    public List<DataField> getByDataId(String dataId) {
        return fieldMapper.selectByDataId(dataId);
    }

    @Override
    public void insert(List<DataField> dataFields) {
        for (DataField dataField : dataFields)
            fieldMapper.insertSelective(dataField);
    }
}
